 $.browser={};
 $.browser.mozilla = /firefox/.test(navigator.userAgent.toLowerCase());
 $.browser.webkit = /webkit/.test(navigator.userAgent.toLowerCase());
 $.browser.opera = /opera/.test(navigator.userAgent.toLowerCase());
 $.browser.msie = /msie/.test(navigator.userAgent.toLowerCase());
 /**
		devtools.uni_encode//Unicode编码
		devtools.uni_decode// Unicode解码
		devtools.base64_encode//base64编码
		devtools.base64_decode//base64解码
		devtools.utf8_encode// UTF-8编码
		devtools.utf8_decode// UTF-8解码
		devtools.utf16to8//utf16转utf8
		devtools.md5://md5
**/

;(function(win) {
 var devtools= function() {
	var hexcase = 0,b64pad = "",chrsz = 8;
	var a = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
		b = new Array(-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1),
		c = function(a) {
			a = escape(a.toString()).replace(/\+/g, "%2B");
			var b = a.match(/(%([0-9A-F]{2}))/gi);
			if(b)
				for(var c = 0; c < b.length; c++) {
					var d = b[c].substring(1, 3);
					parseInt(d, 16) >= 128 && (a = a.replace(b[c], "%u00" + d))
				}
			return a = a.replace("%25", "%u0025").replace(/%/g, "\\"), a
		},
		d = function(a) {
			a = a.replace(/\\/g, "%").replace("%u0025", "%25"), a = unescape(a.toString().replace(/%2B/g, "+"));
			var b = a.match(/(%u00([0-9A-F]{2}))/gi);
			if(b)
				for(var c = 0; c < b.length; c++) {
					var d = b[c].substring(1, 3),
						e = Number("0x" + d);
					e >= 128 && (a = a.replace(b[c], d))
				}
			return a = unescape(a.toString().replace(/%2B/g, "+")), a
		},
		e = function(a) {
			var b, c, d, e;
			b = "", d = a.length;
			for(c = 0; c < d; c++) e = a.charCodeAt(c), e >= 1 && e <= 127 ? b += a.charAt(c) : e > 2047 ? (b += String.fromCharCode(224 | e >> 12 & 15), b += String.fromCharCode(128 | e >> 6 & 63), b += String.fromCharCode(128 | e >> 0 & 63)) : (b += String.fromCharCode(192 | e >> 6 & 31), b += String.fromCharCode(128 | e >> 0 & 63));
			return b
		},
		f = function(a) {
			var b, c, d, e, f, g;
			b = "", d = a.length, c = 0;
			while(c < d) {
				e = a.charCodeAt(c++);
				switch(e >> 4) {
					case 0:
					case 1:
					case 2:
					case 3:
					case 4:
					case 5:
					case 6:
					case 7:
						b += a.charAt(c - 1);
						break;
					case 12:
					case 13:
						f = a.charCodeAt(c++), b += String.fromCharCode((e & 31) << 6 | f & 63);
						break;
					case 14:
						f = a.charCodeAt(c++), g = a.charCodeAt(c++), b += String.fromCharCode((e & 15) << 12 | (f & 63) << 6 | (g & 63) << 0)
				}
			}
			return b
		},
		g = function(b) {
			var c, d, e, f, g, h;
			e = b.length, d = 0, c = "";
			while(d < e) {
				f = b.charCodeAt(d++) & 255;
				if(d == e) {
					c += a.charAt(f >> 2), c += a.charAt((f & 3) << 4), c += "==";
					break
				}
				g = b.charCodeAt(d++);
				if(d == e) {
					c += a.charAt(f >> 2), c += a.charAt((f & 3) << 4 | (g & 240) >> 4), c += a.charAt((g & 15) << 2), c += "=";
					break
				}
				h = b.charCodeAt(d++), c += a.charAt(f >> 2), c += a.charAt((f & 3) << 4 | (g & 240) >> 4), c += a.charAt((g & 15) << 2 | (h & 192) >> 6), c += a.charAt(h & 63)
			}
			return c
		},
		h = function(a) {
			var c, d, e, f, g, h, i;
			h = a.length, g = 0, i = "";
			while(g < h) {
				do c = b[a.charCodeAt(g++) & 255]; while (g < h && c == -1);
				if(c == -1) break;
				do d = b[a.charCodeAt(g++) & 255]; while (g < h && d == -1);
				if(d == -1) break;
				i += String.fromCharCode(c << 2 | (d & 48) >> 4);
				do {
					e = a.charCodeAt(g++) & 255;
					if(e == 61) return i;
					e = b[e]
				} while (g < h && e == -1);
				if(e == -1) break;
				i += String.fromCharCode((d & 15) << 4 | (e & 60) >> 2);
				do {
					f = a.charCodeAt(g++) & 255;
					if(f == 61) return i;
					f = b[f]
				} while (g < h && f == -1);
				if(f == -1) break;
				i += String.fromCharCode((e & 3) << 6 | f)
			}
			return i
		},
		i = function(a) {
			var b, c, d, e;
			b = "", d = a.length;
			for(c = 0; c < d; c++) e = a.charCodeAt(c), e >= 1 && e <= 127 ? b += a.charAt(c) : e > 2047 ? (b += String.fromCharCode(224 | e >> 12 & 15), b += String.fromCharCode(128 | e >> 6 & 63), b += String.fromCharCode(128 | e >> 0 & 63)) : (b += String.fromCharCode(192 | e >> 6 & 31), b += String.fromCharCode(128 | e >> 0 & 63));
			return b
		};

var hex_md5=function(a) {
	return binl2hex(core_md5(str2binl(a), a.length * chrsz))
};
var b64_md5=function(a) {
	return binl2b64(core_md5(str2binl(a), a.length * chrsz))
};

var str_md5=function(a) {
	return binl2str(core_md5(str2binl(a), a.length * chrsz))
};

var hex_hmac_md5=function(a, b) {
	return binl2hex(core_hmac_md5(a, b))
};

var b64_hmac_md5=function(a, b) {
	return binl2b64(core_hmac_md5(a, b))
};

var str_hmac_md5=function(a, b) {
	return binl2str(core_hmac_md5(a, b))
};

var md5_vm_test=function() {
	return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72"
};

var core_md5=function(a, b) {
	a[b >> 5] |= 128 << b % 32, a[(b + 64 >>> 9 << 4) + 14] = b;
	var c = 1732584193,
		d = -271733879,
		e = -1732584194,
		f = 271733878;
	for(var g = 0; g < a.length; g += 16) {
		var h = c,
			i = d,
			j = e,
			k = f;
		c = md5_ff(c, d, e, f, a[g + 0], 7, -680876936), f = md5_ff(f, c, d, e, a[g + 1], 12, -389564586), e = md5_ff(e, f, c, d, a[g + 2], 17, 606105819), d = md5_ff(d, e, f, c, a[g + 3], 22, -1044525330), c = md5_ff(c, d, e, f, a[g + 4], 7, -176418897), f = md5_ff(f, c, d, e, a[g + 5], 12, 1200080426), e = md5_ff(e, f, c, d, a[g + 6], 17, -1473231341), d = md5_ff(d, e, f, c, a[g + 7], 22, -45705983), c = md5_ff(c, d, e, f, a[g + 8], 7, 1770035416), f = md5_ff(f, c, d, e, a[g + 9], 12, -1958414417), e = md5_ff(e, f, c, d, a[g + 10], 17, -42063), d = md5_ff(d, e, f, c, a[g + 11], 22, -1990404162), c = md5_ff(c, d, e, f, a[g + 12], 7, 1804603682), f = md5_ff(f, c, d, e, a[g + 13], 12, -40341101), e = md5_ff(e, f, c, d, a[g + 14], 17, -1502002290), d = md5_ff(d, e, f, c, a[g + 15], 22, 1236535329), c = md5_gg(c, d, e, f, a[g + 1], 5, -165796510), f = md5_gg(f, c, d, e, a[g + 6], 9, -1069501632), e = md5_gg(e, f, c, d, a[g + 11], 14, 643717713), d = md5_gg(d, e, f, c, a[g + 0], 20, -373897302), c = md5_gg(c, d, e, f, a[g + 5], 5, -701558691), f = md5_gg(f, c, d, e, a[g + 10], 9, 38016083), e = md5_gg(e, f, c, d, a[g + 15], 14, -660478335), d = md5_gg(d, e, f, c, a[g + 4], 20, -405537848), c = md5_gg(c, d, e, f, a[g + 9], 5, 568446438), f = md5_gg(f, c, d, e, a[g + 14], 9, -1019803690), e = md5_gg(e, f, c, d, a[g + 3], 14, -187363961), d = md5_gg(d, e, f, c, a[g + 8], 20, 1163531501), c = md5_gg(c, d, e, f, a[g + 13], 5, -1444681467), f = md5_gg(f, c, d, e, a[g + 2], 9, -51403784), e = md5_gg(e, f, c, d, a[g + 7], 14, 1735328473), d = md5_gg(d, e, f, c, a[g + 12], 20, -1926607734), c = md5_hh(c, d, e, f, a[g + 5], 4, -378558), f = md5_hh(f, c, d, e, a[g + 8], 11, -2022574463), e = md5_hh(e, f, c, d, a[g + 11], 16, 1839030562), d = md5_hh(d, e, f, c, a[g + 14], 23, -35309556), c = md5_hh(c, d, e, f, a[g + 1], 4, -1530992060), f = md5_hh(f, c, d, e, a[g + 4], 11, 1272893353), e = md5_hh(e, f, c, d, a[g + 7], 16, -155497632), d = md5_hh(d, e, f, c, a[g + 10], 23, -1094730640), c = md5_hh(c, d, e, f, a[g + 13], 4, 681279174), f = md5_hh(f, c, d, e, a[g + 0], 11, -358537222), e = md5_hh(e, f, c, d, a[g + 3], 16, -722521979), d = md5_hh(d, e, f, c, a[g + 6], 23, 76029189), c = md5_hh(c, d, e, f, a[g + 9], 4, -640364487), f = md5_hh(f, c, d, e, a[g + 12], 11, -421815835), e = md5_hh(e, f, c, d, a[g + 15], 16, 530742520), d = md5_hh(d, e, f, c, a[g + 2], 23, -995338651), c = md5_ii(c, d, e, f, a[g + 0], 6, -198630844), f = md5_ii(f, c, d, e, a[g + 7], 10, 1126891415), e = md5_ii(e, f, c, d, a[g + 14], 15, -1416354905), d = md5_ii(d, e, f, c, a[g + 5], 21, -57434055), c = md5_ii(c, d, e, f, a[g + 12], 6, 1700485571), f = md5_ii(f, c, d, e, a[g + 3], 10, -1894986606), e = md5_ii(e, f, c, d, a[g + 10], 15, -1051523), d = md5_ii(d, e, f, c, a[g + 1], 21, -2054922799), c = md5_ii(c, d, e, f, a[g + 8], 6, 1873313359), f = md5_ii(f, c, d, e, a[g + 15], 10, -30611744), e = md5_ii(e, f, c, d, a[g + 6], 15, -1560198380), d = md5_ii(d, e, f, c, a[g + 13], 21, 1309151649), c = md5_ii(c, d, e, f, a[g + 4], 6, -145523070), f = md5_ii(f, c, d, e, a[g + 11], 10, -1120210379), e = md5_ii(e, f, c, d, a[g + 2], 15, 718787259), d = md5_ii(d, e, f, c, a[g + 9], 21, -343485551), c = safe_add(c, h), d = safe_add(d, i), e = safe_add(e, j), f = safe_add(f, k)
	}
	return Array(c, d, e, f)
};

var md5_cmn=function(a, b, c, d, e, f) {
	return safe_add(bit_rol(safe_add(safe_add(b, a), safe_add(d, f)), e), c)
};

var md5_ff=function(a, b, c, d, e, f, g) {
	return md5_cmn(b & c | ~b & d, a, b, e, f, g)
};

var md5_gg=function(a, b, c, d, e, f, g) {
	return md5_cmn(b & d | c & ~d, a, b, e, f, g)
};

var md5_hh=function(a, b, c, d, e, f, g) {
	return md5_cmn(b ^ c ^ d, a, b, e, f, g)
};

var md5_ii=function(a, b, c, d, e, f, g) {
	return md5_cmn(c ^ (b | ~d), a, b, e, f, g)
};

var core_hmac_md5=function(a, b) {
	var c = str2binl(a);
	c.length > 16 && (c = core_md5(c, a.length * chrsz));
	var d = Array(16),
		e = Array(16);
	for(var f = 0; f < 16; f++) d[f] = c[f] ^ 909522486, e[f] = c[f] ^ 1549556828;
	var g = core_md5(d.concat(str2binl(b)), 512 + b.length * chrsz);
	return core_md5(e.concat(g), 640)
};

var safe_add=function(a, b) {
	var c = (a & 65535) + (b & 65535),
		d = (a >> 16) + (b >> 16) + (c >> 16);
	return d << 16 | c & 65535
};

var bit_rol=function(a, b) {
	return a << b | a >>> 32 - b
};

var str2binl=function(a) {
	var b = Array(),
		c = (1 << chrsz) - 1;
	for(var d = 0; d < a.length * chrsz; d += chrsz) b[d >> 5] |= (a.charCodeAt(d / chrsz) & c) << d % 32;
	return b
};

var binl2str=function(a) {
	var b = "",
		c = (1 << chrsz) - 1;
	for(var d = 0; d < a.length * 32; d += chrsz) b += String.fromCharCode(a[d >> 5] >>> d % 32 & c);
	return b
};

var binl2hex = function(a) {
	var b = hexcase ? "0123456789ABCDEF" : "0123456789abcdef",
		c = "";
	for(var d = 0; d < a.length * 4; d++) c += b.charAt(a[d >> 2] >> d % 4 * 8 + 4 & 15) + b.charAt(a[d >> 2] >> d % 4 * 8 & 15);
	return c
};

var binl2b64 = function(a) {
	var b = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
		c = "";
	for(var d = 0; d < a.length * 4; d += 3) {
		var e = (a[d >> 2] >> 8 * (d % 4) & 255) << 16 | (a[d + 1 >> 2] >> 8 * ((d + 1) % 4) & 255) << 8 | a[d + 2 >> 2] >> 8 * ((d + 2) % 4) & 255;
		for(var f = 0; f < 4; f++) d * 8 + f * 6 > a.length * 32 ? c += b64pad : c += b.charAt(e >> 6 * (3 - f) & 63)
	}
	return c
};
 return {
		uni_encode: c,//Unicode编码
		uni_decode: d,// Unicode解码
		base64_encode: g,//base64编码
		base64_decode: h,//base64解码
		utf8_encode: e,// UTF-8编码
		utf8_decode: f,// UTF-8解码
		utf16to8: i,//
		md5:hex_md5//md5
	}
  }();
  win.devtools =devtools;
})(window);


function hideMenu(){
	$("#result_code").select();
	$("#result_code").focus();
	$("#result_text").text("复制成功！");
}

$(function(){
	$("#js_escape").click(function(){
		$("#result_code").val(escape($("#code").val()));
		$("#result_text").text("");
	});

	$("#js_unescape").click(function(){
		$("#result_code").val(unescape($("#code").val())); 
		$("#result_text").text("");
	});	
		
	$("#gb2312_encode").click(function(){
		$("#result_text").text("请稍候...");
		$.post("url_en-decode.php", {action:"encode", charset:"gb2312", str:$("#code").val()}, function(msg){
			$("#result_code").val(msg);
			$("#result_text").text("");
		});
	});

	$("#gb2312_decode").click(function(){
		$("#result_text").text("请稍候...");
		$.post("url_en-decode.php", {action:"decode", charset:"gb2312", str:$("#code").val()}, function(msg){
			$("#result_code").val(msg);
			$("#result_text").text("");
		});
	});
	

	$("#utf8_encode").click(function(){
		$("#result_text").text("请稍候...");
		$.post("url_en-decode.php", {action:"encode", charset:"utf-8", str:$("#code").val()}, function(msg){
			$("#result_code").val(msg);
			$("#result_text").text("");
		});
	});

	$("#utf8_decode").click(function(){
		$("#result_text").text("请稍候...");
		$.post("url_en-decode.php", {action:"decode", charset:"utf-8", str:$("#code").val()}, function(msg){
			$("#result_code").val(msg);
			$("#result_text").text("");
		});
	});

	$("#md5_encode").click(function(){
 		$("#result_code").val(devtools.md5($("#code").val()));
		$("#result_text").text("");
 
	});

	$("#base64_encode").click(function(){
		$("#result_code").val(devtools.base64_encode($("#code").val()));
		$("#result_text").text("");
	});

	$("#base64_decode").click(function(){
		$("#result_code").val(devtools.base64_decode($("#code").val())); 
		$("#result_text").text("");
	});	

	$("#clear").click(function(){
		$("#code").val("");
		$("#result_code").val("");
		$("#result_text").text("");
	});	

});